﻿//-------------------------------------
// WBFSSync - WBFSSync.exe
//
// Copyright 2009 Caian (ÔmΣga Frøst) <frost.omega@hotmail.com>
//
// WBFSSync is Licensed under the terms of the Microsoft Reciprocal License (Ms-RL)
//
// WBFSDrive.cs:
//
// Implementação da interface que guarda informações sobre dispositivos de armazenagem conectados ao computador
// específica para Drives WBFS
//
//-------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WBFSSync
{
    public class WBFSDrive : IDrive
    {
        public WBFSDevice _Device = new WBFSDevice();
        public DriveFlags _Flags = DriveFlags.Unknown;

        public long transfer = 0;
        int numoperations = 0;

        public string Name { get { return _Device.Name; } }
        public string Label { get { return _Device.Label; } }
        public DriveFlags Flags { get { return _Flags; } }

        public Boolean Ready { get { return _Device.Ready; } }

        public long Size { get { return _Device.Size; } }
        public long FreeSpace { get { return _Device.Free; } }
        public long UsedSpace { get { return _Device.Used; } }
        public long ReservedSpace { get { return transfer; } set { transfer = Math.Max(value, 0); } }

        public bool Is(DriveFlags flag) { return (_Flags & flag) != DriveFlags.Unknown; }

        public Int32 ActiveOperations { get { return numoperations; } set { numoperations = value; } }

        public int Open(Char d)
        {
            return _Device.Open(d.ToString(), false);
        }

        public void Close()
        {
            _Device.Close();
            _Device = null;
        }

        public void Refresh()
        {
            _Device.EnumerateDiscs();
            _Device.GetDeviceInfo();
        }
    }
}
